package cn.com.guanying.android.ui;

import android.content.Intent;
import android.os.Handler;
import android.widget.Toast;
import cn.com.guanying.R;
import cn.com.guanying.android.logic.LogicMgr;
import cn.com.guanying.android.logic.LoginLogic;
public class StartActivity extends BaseActivity{
	private long stayTime = 1000;//页面停留时间
	private int isCandNext = 0;//是否可以跳转到下一页
	public void doInit() {
		new Handler().postDelayed(new Thread(){
			public void run(){
				toNextPage();
			}
		}, stayTime);
		LogicMgr.getLoginLogic().getMNAV();
		LogicMgr.getLoginLogic().getFilmList();
	}
	@Override
	public void doFindView() {
		
	}

	
	protected void addInterestedThing() {
		LogicMgr.getLoginLogic().addListener(this, LoginLogic.EVENT_REQ_MNAV, LoginLogic.EVENT_GETMNAV_ERROR);
	}

	protected void deleteInterestedThing() {
		LogicMgr.getLoginLogic().removeListener(this);
	}
	/**
	 * 跳转到下一个页面
	 */
	public void toNextPage(){
		if(isCandNext > 0){
			isCandNext = 0;
			Intent intent = new Intent(this,HomeGroupActivity.class);
			startActivity(intent);
			finish();
		}else{
			isCandNext++;
		}
	}
	protected void onLogicEventUI(Object sender, int eventId, Object[] datas) {	
		if(sender==LogicMgr.getLoginLogic()){
			if(eventId==LoginLogic.EVENT_REQ_MNAV){
				toNextPage();
			}else if(eventId==LoginLogic.EVENT_GETMNAV_ERROR){
				toast("请求失败");
				toNextPage();
			}
		}
	}

	protected int getContentView() {
		return R.layout.activity_start;
	} 
}
